03 / 05

How do we modify Request or Response Dynamically

cy.intercept() lets you:​
  1. 1

    Cypress intercepts a POST request to /api/login.

  2. 2

    It doesn’t block the request immediately — instead, it uses a callback to manipulate the response.

  3. 3

    In this case, it fakes the login token in the reply.

You want to customize responses on the fly, or perhaps simulate a successful login without hitting a real auth server.